package com.lagou.springbootwork.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lagou.springbootwork.entity.Article;
import com.lagou.springbootwork.mapper.ArticleMpper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName ArticleServiceImpl
 * @Deseription TODO
 * @Author fx
 * @Date 2021/1/7 0007 21:57
 * @Version 1.0
 **/
@Service
public class ArticleServiceImpl implements IArticleService{

    @Autowired
    private ArticleMpper articleMpper;

    @Override
    public PageInfo getAllByPage(int page,int size) throws Exception {
        PageHelper.startPage(page,size);
        List<Article> list =  articleMpper.getAll();
        return new PageInfo(list);
    }

    @Override
    public Article getById(Integer id) throws Exception {
        return articleMpper.getById(id);
    }
}
